package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.Reservation;
import com.zzyl.vo.ReservationVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface ReservationMapper {
  @Select("SELECT COUNT(0) FROM `reservation` where create_by=#{id} and status=2 and type=0 ")
  Long getCount(Long id);
  void addReservation(Reservation reservationDto);

  List<ReservationVo>  getCountByTime(LocalDate time);

  Page<Reservation> selectByPage(Integer status);
  @Update("update reservation set status=2 where id=#{id}")
  void cancel(Long id);

  @Update("update reservation set status=2 where `time` <= NOW()")
  void expired();
}
